#ifndef UART_H
#define UART_H
#include<iostream>
#include <ros/ros.h>
#include <serial/serial.h>
#include "unionsys_msgs/TrackRectangle.h"
#include "unionsys_msgs/Gimbal_PidVel_cmd.h"
using namespace serial;
using namespace std;

typedef struct{
    std::vector<uint8_t> rx_buffer;
    uint8_t rx_over;
    uint8_t index;
}serial_process_t;

typedef struct{
    uint16_t xmin;
    uint16_t ymin;
    uint16_t xmax;
    uint16_t ymax;
} track_rect;

class UART : public Serial
{
public:
    UART();
    void OpenSerial();
    void RunMain();
    uint8_t CrcCheck(std::vector<uint8_t> buff, int len);
    char *CrcCheckForGimbal(char *ch, int len);
    void GimbalVelCallback(const unionsys_msgs::Gimbal_PidVel_cmd &msg);
    char *StringToHex_s(char *String, int Inlen);
    string DecIntToHexStr(uint8_t num);

public:
    std::string _port;
    int         _baudrate;
    Timeout     _to;

    track_rect  _rect;

    ros::Publisher  _rect_pub;
    ros::Subscriber _gimbal_vel_sub;
};

#endif // UART_H
